﻿using System;
using System.Collections.Generic;
using System.Transactions;
using Bingosoft.Data;
using HHMMS.Core.Model;

namespace HHMMS.Core.Service
{
	/// <summary>
	///表示对表MaterialDirectoryService的所有操作的实现。
	/// </summary>
    public class MaterialDirectoryService
    {
		private readonly Dao dao = Dao.Get();

        private MaterialDirectoryService()
		{}

        private static MaterialDirectoryService instance = null;
		/// <summary>
		/// MaterialDirectory服务类的单例。
		/// </summary>
        public static MaterialDirectoryService Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (typeof(MaterialDirectoryService))
                    {
                        instance = new MaterialDirectoryService();
                    }
                }
                return instance;
            }
        }

        public void Delete(string materialsNo)
		{
            Dictionary<string, object> param = new Dictionary<string, object>() { { "MaterialsNo", materialsNo } };
            this.dao.ExecuteNonQuery("MaterialDirectory.delete", param);
		}
		
		public void Insert(MaterialDirectory materialDirectory)
		{
            this.dao.ExecuteNonQuery("MaterialDirectory.insert", materialDirectory);
		}

        public void Update(MaterialDirectory materialDirectory)
		{
            this.dao.ExecuteNonQuery("psims.MaterialDirectory.update", materialDirectory);
		}

        public MaterialDirectory Single(string materialsNo)
		{
            Dictionary<string, object> param = new Dictionary<string, object>() { { "MaterialsNo", materialsNo } };
            return this.dao.QueryEntity<MaterialDirectory>("MaterialDirectory.single", param);
		}

        public void SaveOrUpdate(MaterialDirectory materialDirectory)
        {
            this.dao.ExecuteNonQuery("MaterialDirectory.insertOrUpdate", materialDirectory);
        }
    }
}